package com.btpn.custody.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.btpn.custody.dao.IGroupRole;
import com.btpn.custody.dao.IUser;
import com.btpn.custody.entity.User;
import com.btpn.custody.service.IGroupRoleService;

@Service("groupRoleService")
@Transactional
public class GroupRoleServiceImpl implements IGroupRoleService{
	
	@Autowired
	private IGroupRole groupRoleDaoHibernate;

	@Autowired
	private IUser userDaoHibernate;
	
	@Override
	public void deleteGroupRole(Long groupRoleId) {
		for (User user : userDaoHibernate.findByGroupRole(groupRoleId)) {
			user.setGroupRole(null);
		}
		groupRoleDaoHibernate.delete(groupRoleId);
	}
}
